home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IRIX 6.5 Applications 2004 April
/
SGI IRIX 6.5 Applications 2004 April.iso
/
dist
/
appletalk.idb
/
usr
/
etc
/
appletalk
/
ksd_restart.z
/
ksd_restart
Wrap
Text File
|
2002-03-07
|
3KB
|
129 lines
#!/bin/csh -f
#
# @(#)ksd_restart 10.3 00/02/01 Xinet, Inc.
#
# ksd_restart - halt/restart AppleShare
# usage: ksd_retart [servername]
#
#
set BIN=/usr/etc/appletalk
set path=(${BIN} /bin /etc /usr/{bin,ucb,bsd} /usr/etc .)
set ADM=/var/adm/appletalk
set SERVICES=${BIN}/services
if (-x /bin/id) then
if (`/bin/id | grep -c uid=0` > 0) then
set me=root
else
set me=notroot
endif
else
set me=`whoami`
endif
if ("$me" != root) then
echo "You must have root privileges to run this script"
exit 1
endif
if ("$1" == "") then
set pid=`grep AFPServer ${ADM}/nbpreg_pids | tail -1 | awk '{print $1}'`
set name=`grep AFPServer ${ADM}/nbpreg_pids | tail -1 | awk '{print $2}'`
else
set pid=`grep "$1" ${ADM}/nbpreg_pids | grep AFPServer | tail -1 | awk '{print $ 1}'`
set name="$1"
endif
if ("$pid" == "0" || "$pid" == "") then
set pid=`grep XinetServer ${ADM}/nbpreg_pids | tail -1 | awk '{print $1}'`
endif
if ("$pid" == "0" || "$pid" == "") then
if ("$1" == "") then
echo "I don't see a AppleShare server running on this machine"
else
echo "I don't see AppleShare server $1 running on this machine"
endif
goto restart
endif
repprint:
echo -n "Do you really want to halt the AppleShare daemon? "
set resp=$<
if ("$resp" =~ [Nn]*) then
echo "Leaving AppleShare running."
exit 1
else if ("$resp" !~ [Yy]*) then
echo Please answer \"yes\" or \"no\":
goto repprint
endif
endif
echo -n "Do you want to give the users time to disconnect[y]? "
set resp=$<
if ("$resp" !~ [Nn]*) then
mins:
echo -n "How many minutes do you want to wait[2]: "
set mins=$<
if ($mins == "") then
set mins = "2"
endif
@ secs = $mins * 60
if ($mins != "0" && $secs == "0") then
echo "Invalid minutes $mins, try again."
goto mins
endif
echo -n "Do you want customize the logout message[n]? "
set resp=$<
if ("$resp" =~ [Yy]*) then
echo "Enter the logout message now, followed by a ^D"
cat > /tmp/ksmessage.$$
else
echo "AppleShare being shut down" > /tmp/ksmessage.$$
endif
while ($mins != "0")
rm -f ${ADM}/msg
echo " $mins" > ${ADM}/msg
cat /tmp/ksmessage.$$ >> ${ADM}/msg
chmod 644 ${ADM}/msg
kill -USR2 $pid
echo "Server will shut down in $mins minute(s)"
@ mins--
sleep 60
end
rm -f ${ADM}/msg
rm -f /tmp/ksmessage.$$
endif
echo "Killing the daemon..."
set res=`kill $pid`
if ($status) then
echo "Error killing daemon: $res"
echo "Attempting to remove registered name"
nbpremove -T AFPServer -O $name
if (-r ${ADM}/serial) then
set s=`cat ${ADM}/serial`
if ("$s" != "") nbpremove -T XinetServer -O $s
endif
endif
sleep 5
set newpid=`grep AFPServer ${ADM}/nbpreg_pids | tail -1 | awk '{print $1}'`
if ("$newpid" == "$pid") then
echo "ERROR: The daemon did not die."
exit 1
endif
restart:
set noglob
set line=`grep ksd ${SERVICES} | tail -1`
echo -n "Do you want to re-start the AppleShare daemon[y]? "
set resp=$<
if ("$resp" !~ [nN]*) then
echo "Restarting AppleShare $line"
echo $line | csh -fe
endif